var codeFlag = 0;//用于判断验证码是否发送
var codeCount = 60;
var timeBean = null;

function submit() {
    $.ajax({
        type: "post",
        url: common.modificationUserPassWordUrl,
        data: $('#myForm').serialize(),
        success: function (result) {
            //这里是解析的json数据   直接返回data
            var resultDate = result;
            var data = resultDate.data;
            console.log(resultDate);
            var list = data.states;
            if (resultDate.code == 0) {
                common.showMsgTips("修改成功");
                window.location = 'success.html?type=pwd';
            } else {
                common.showMsgTips(resultDate.msg);
            }
        }
    });
}

function sendCode(bean) {
    if (codeFlag == 0) {
        codeFlag = 1;
        $.ajax({
            type: "get",
            url: common.resetPasswordsUrl,
            data: $('#myForm').serialize(),
            success: function (result) {
                //这里是解析的json数据   直接返回data
                var resultDate = result;
                console.log(resultDate);
            }
        });
        timeBean = window.setInterval(function () {
            codeCount--;
            $(bean).text("已发送 " + codeCount + "s");
            if (codeCount <= 0) {
                window.clearInterval(timeBean); //停止计时器
                $(bean).css("color", "#22a3f9");
                $(bean).css("border", " 1px solid #22a3f9");
                $(bean).text("发送验证码");
                codeFlag = 0;
                codeCount = 60;
            }
        }, 1000); //启动计时器，1秒执行一次
        $(bean).css("color", "#cccccc");
        $(bean).css("border", " 1px solid #cccccc");
    }
}


